home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / Tool Chest / Development Platforms / MPW Related / MPW Interfaces / CIncludes / Connections.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-17  |  7.6 KB  |  282 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Connections.h
  3.  
  4.     Copyright:    © 1983-1993 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Version:    System 7.1 for ETO #11
  8.     Created:    Tuesday, March 30, 1993 18:00
  9.  
  10. */
  11.  
  12. #ifndef __CONNECTIONS__
  13. #define __CONNECTIONS__
  14.  
  15. #ifndef __DIALOGS__
  16. #include <Dialogs.h>
  17. #endif
  18.  
  19. #ifndef __CTBUTILITIES__
  20. #include <CTBUtilities.h>
  21. #endif
  22.  
  23.  
  24. enum {
  25.  
  26.  
  27. /*    current Connection Manager version    */
  28.  curCMVersion = 2,
  29.  
  30. /*    current Connection Manager Environment Record version     */
  31.  curConnEnvRecVers = 0,
  32.  
  33. /* CMErr */
  34.  cmGenericError = -1,
  35.  cmNoErr = 0,
  36.  cmRejected = 1,
  37.  cmFailed = 2,
  38.  cmTimeOut = 3,
  39.  cmNotOpen = 4,
  40.  cmNotClosed = 5,
  41.  cmNoRequestPending = 6,
  42.  cmNotSupported = 7,
  43.  cmNoTools = 8,
  44.  cmUserCancel = 9,
  45.  cmUnknownError = 11
  46. };
  47.  
  48. typedef OSErr CMErr;
  49.  
  50. enum {
  51.   cmData    = 1 << 0,
  52.  cmCntl    = 1 << 1,
  53.  cmAttn    = 1 << 2,
  54.  cmDataNoTimeout = 1 << 4,
  55.  cmCntlNoTimeout = 1 << 5,
  56.  cmAttnNoTimeout = 1 << 6,
  57.  cmDataClean  = 1 << 8,  
  58.  cmCntlClean  = 1 << 9,
  59.  cmAttnClean  = 1 << 10,
  60. /*  Only for CMRecFlags (not CMChannel) in the rest of this enum */
  61.  cmNoMenus   = 1 << 16, 
  62.  cmQuiet   = 1 << 17,
  63.  cmConfigChanged   = 1 << 18
  64. };
  65.  
  66. /* CMRecFlags and CMChannel  */
  67. /*  Low word of CMRecFlags is same as CMChannel */
  68. typedef long CMRecFlags;
  69.  
  70.  
  71. typedef short CMChannel;
  72.  
  73. enum {
  74.  cmStatusOpening = 1 << 0,
  75.  cmStatusOpen = 1 << 1,
  76.  cmStatusClosing = 1 << 2,
  77.  cmStatusDataAvail  = 1 << 3,
  78.  cmStatusCntlAvail  = 1 << 4,
  79.  cmStatusAttnAvail  = 1 << 5,
  80.  
  81.  cmStatusDRPend   = 1 << 6,     /* data read pending */
  82.  cmStatusDWPend   = 1 << 7,     /* data write pending */
  83.  cmStatusCRPend   = 1 << 8,     /* cntl read pending */
  84.  cmStatusCWPend   = 1 << 9,     /* cntl write pending */
  85.  cmStatusARPend   = 1 << 10,     /* attn read pending */
  86.  cmStatusAWPend   = 1 << 11,     /* attn write pending */
  87.  
  88.  cmStatusBreakPend  = 1 << 12,
  89.  cmStatusListenPend  = 1 << 13,
  90.  cmStatusIncomingCallPresent = 1 << 14,
  91.  
  92.  cmStatusReserved0 = 1 << 15
  93. };
  94. typedef unsigned long CMStatFlags;
  95.  
  96. enum {cmDataIn,cmDataOut,cmCntlIn,cmCntlOut,cmAttnIn,cmAttnOut,cmRsrvIn,
  97.  cmRsrvOut};
  98. typedef unsigned short CMBufFields;
  99.  
  100.  
  101. typedef Ptr CMBuffers[8];
  102. typedef long CMBufferSizes[8];
  103. typedef const long *ConstCMBufferSizesParam;
  104.  
  105. enum {cmSearchSevenBit = 1 << 0};
  106. typedef unsigned short CMSearchFlags;
  107.  
  108. enum {cmFlagsEOM  = 1 << 0};
  109. typedef unsigned short CMFlags;
  110.  
  111.  
  112. struct ConnEnvironRec {
  113.  short version;
  114.  long baudRate;
  115.  short dataBits;
  116.  CMChannel channels;
  117.  Boolean swFlowControl;
  118.  Boolean hwFlowControl;
  119.  CMFlags flags;
  120. };
  121.  
  122. typedef struct ConnEnvironRec ConnEnvironRec;
  123. typedef ConnEnvironRec *ConnEnvironRecPtr;
  124.  
  125. struct ConnRecord {
  126.  short procID;
  127.  CMRecFlags flags;
  128.  CMErr errCode;
  129.  long refCon;
  130.  long userData;
  131.  ProcPtr defProc;
  132.  Ptr config;
  133.  Ptr oldConfig;
  134.  long asyncEOM;
  135.  long reserved1;
  136.  long reserved2;
  137.  Ptr cmPrivate;
  138.  CMBuffers bufferArray;
  139.  CMBufferSizes bufSizes;
  140.  long mluField;
  141.  CMBufferSizes asyncCount;
  142. };
  143.  
  144. typedef struct ConnRecord ConnRecord;
  145. typedef ConnRecord *ConnPtr, **ConnHandle;
  146.  
  147.  
  148. /* application routines type definitions */
  149. typedef pascal void  (*ConnectionSearchCallBackProcPtr) (ConnHandle hConn, Ptr matchPtr, long refNum);
  150. typedef pascal void  (*ConnectionCompletionProcPtr) (ConnHandle hConn);
  151. typedef pascal void  (*ConnectionChooseIdleProcPtr) (void);
  152.  
  153. enum {
  154.  
  155.  
  156. /* CMIOPB constants and structure */
  157.  cmIOPBQType = 10,
  158.  cmIOPBversion = 0
  159. };
  160.  
  161. struct CMIOPB {
  162.  QElemPtr qLink;
  163.  short qType;                    /* cmIOPBQType */
  164.  ConnHandle hConn;
  165.  Ptr theBuffer;
  166.  long count;
  167.  CMFlags flags;
  168.  ConnectionCompletionProcPtr userCompletion;
  169.  long timeout;
  170.  CMErr errCode;
  171.  CMChannel channel;
  172.  long asyncEOM;
  173.  long reserved1;
  174.  short reserved2;
  175.  short version;                    /* cmIOPBversion */
  176.  long refCon;                    /* for application */
  177.  long toolData1;                /* for tool */
  178.  long toolData2;                /* for tool */
  179. };
  180.  
  181. typedef struct CMIOPB CMIOPB;
  182. typedef CMIOPB *CMIOPBPtr;
  183.  
  184.  
  185. #ifdef __cplusplus
  186. extern "C" {
  187. #endif
  188. pascal CMErr InitCM(void); 
  189. pascal Handle CMGetVersion(ConnHandle hConn); 
  190. pascal short CMGetCMVersion(void); 
  191.  
  192. pascal ConnHandle CMNew(short procID,CMRecFlags flags,ConstCMBufferSizesParam desiredSizes,
  193.  long refCon,long userData); 
  194.  
  195. pascal void CMDispose(ConnHandle hConn); 
  196.  
  197. pascal CMErr CMListen(ConnHandle hConn,Boolean async,ConnectionCompletionProcPtr completor,
  198.  long timeout); 
  199. pascal CMErr CMAccept(ConnHandle hConn,Boolean accept); 
  200.  
  201. pascal CMErr CMOpen(ConnHandle hConn,Boolean async,ConnectionCompletionProcPtr completor,
  202.  long timeout); 
  203. pascal CMErr CMClose(ConnHandle hConn,Boolean async,ConnectionCompletionProcPtr completor,
  204.  long timeout,Boolean now); 
  205.  
  206. pascal CMErr CMAbort(ConnHandle hConn); 
  207.  
  208. pascal CMErr CMStatus(ConnHandle hConn,CMBufferSizes sizes,CMStatFlags *flags); 
  209. pascal void CMIdle(ConnHandle hConn); 
  210.  
  211. pascal void CMReset(ConnHandle hConn); 
  212.  
  213. pascal void CMBreak(ConnHandle hConn,long duration,Boolean async,ConnectionCompletionProcPtr completor); 
  214.  
  215. pascal CMErr CMRead(ConnHandle hConn,void *theBuffer,long *toRead,CMChannel theChannel,
  216.  Boolean async,ConnectionCompletionProcPtr completor,long timeout,CMFlags *flags); 
  217. pascal CMErr CMWrite(ConnHandle hConn,const void *theBuffer,long *toWrite,
  218.  CMChannel theChannel,Boolean async,ConnectionCompletionProcPtr completor,
  219.  long timeout,CMFlags flags); 
  220.  
  221. pascal CMErr CMIOKill(ConnHandle hConn,short which); 
  222.  
  223. pascal void CMActivate(ConnHandle hConn,Boolean activate); 
  224. pascal void CMResume(ConnHandle hConn,Boolean resume); 
  225. pascal Boolean CMMenu(ConnHandle hConn,short menuID,short item); 
  226.  
  227. pascal Boolean CMValidate(ConnHandle hConn); 
  228. pascal void CMDefault(Ptr *theConfig,short procID,Boolean allocate); 
  229.  
  230. pascal Handle CMSetupPreflight(short procID,long *magicCookie); 
  231. pascal Boolean CMSetupFilter(short procID,const void *theConfig,short count,
  232.  DialogPtr theDialog,EventRecord *theEvent,short *theItem,long *magicCookie); 
  233. pascal void CMSetupSetup(short procID,const void *theConfig,short count,
  234.  DialogPtr theDialog,long *magicCookie); 
  235. pascal void CMSetupItem(short procID,const void *theConfig,short count,
  236.  DialogPtr theDialog,short *theItem,long *magicCookie); 
  237. pascal void CMSetupXCleanup(short procID,const void *theConfig,short count,
  238.  DialogPtr theDialog,Boolean OKed,long *magicCookie); 
  239. pascal void CMSetupPostflight(short procID); 
  240.  
  241. pascal Ptr CMGetConfig(ConnHandle hConn); 
  242. pascal short CMSetConfig(ConnHandle hConn,const void *thePtr); 
  243.  
  244. pascal OSErr CMIntlToEnglish(ConnHandle hConn,const void *inputPtr,Ptr *outputPtr,
  245.  short language); 
  246. pascal OSErr CMEnglishToIntl(ConnHandle hConn,const void *inputPtr,Ptr *outputPtr,
  247.  short language); 
  248.  
  249. pascal long CMAddSearch(ConnHandle hConn,ConstStr255Param theString,CMSearchFlags flags,
  250.  ConnectionSearchCallBackProcPtr callBack); 
  251. pascal void CMRemoveSearch(ConnHandle hConn,long refnum); 
  252. pascal void CMClearSearch(ConnHandle hConn); 
  253.  
  254. pascal CMErr CMGetConnEnvirons(ConnHandle hConn,ConnEnvironRec *theEnvirons); 
  255.  
  256. pascal short CMChoose(ConnHandle *hConn,Point where,ConnectionChooseIdleProcPtr idleProc); 
  257.  
  258. pascal void CMEvent(ConnHandle hConn,const EventRecord *theEvent); 
  259.  
  260. pascal void CMGetToolName(short procID,Str255 name); 
  261. pascal short CMGetProcID(ConstStr255Param name); 
  262.  
  263. pascal void CMSetRefCon(ConnHandle hConn,long refCon); 
  264. pascal long CMGetRefCon(ConnHandle hConn); 
  265.  
  266. pascal long CMGetUserData(ConnHandle hConn); 
  267. pascal void CMSetUserData(ConnHandle hConn,long userData); 
  268.  
  269. pascal void CMGetErrorString(ConnHandle hConn,short id,Str255 errMsg); 
  270.  
  271. pascal CMErr CMNewIOPB(ConnHandle hConn,CMIOPBPtr *theIOPB); 
  272. pascal CMErr CMDisposeIOPB(ConnHandle hConn,CMIOPBPtr theIOPB); 
  273.  
  274. pascal CMErr CMPBRead(ConnHandle hConn,CMIOPBPtr theIOPB,Boolean async); 
  275. pascal CMErr CMPBWrite(ConnHandle hConn,CMIOPBPtr theIOPB,Boolean async); 
  276. pascal CMErr CMPBIOKill(ConnHandle hConn,CMIOPBPtr theIOPB); 
  277. #ifdef __cplusplus
  278. }
  279. #endif
  280.  
  281. #endif
  282.